package com.softeem.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.softeem.dao.IReservoirDao;
import com.softeem.model.Reservoir;
import com.softeem.model.User;
import com.softeem.service.IReservoirService;
import com.softeem.service.IUserService;

@Controller
@RequestMapping("/user")
public class UserController {
	@Resource
    private IUserService userService;
	@Resource
	private IReservoirService  reservoirService; 
	
	 /*
     * 用户列表与分页Action
     */
    @RequestMapping("/list")
    public String list(Model model,@RequestParam(required=false,defaultValue="1") int pageNO){
        int size=5;
        model.addAttribute("size",size);
        model.addAttribute("pageNO",pageNO);
        model.addAttribute("count",userService.queryUserCount());
        return "user/list";
    }
    
    @RequestMapping("/list2")
    @ResponseBody
    public Map<String,Object> list(Model model,Reservoir r){
    
    	Map<String,Object> result=new HashMap<String, Object>();
    	int num=reservoirService.queryReservoirCount();
        List<Reservoir> rows=new ArrayList<Reservoir>();
        rows=reservoirService.queryReservoirs(r);
    	result.put("rows",rows);
    	result.put("total",num);
    	result.put("status",200);
    	result.put("msg","获取数据成功");
    	
     
        return result;
    }
    
    @RequestMapping("/list1")
    @ResponseBody
    public Map<String,Object> list2(Model model){
    	Map<String,Object> result=new HashMap<String, Object>();
    	
   
  
        
       
       

        
    
        
       
     
        return result;
    }
    
    
    
	
	

}
